package priv.pattern.iteratorpattern.setvice.impl;

import priv.pattern.iteratorpattern.pojo.Student;
import priv.pattern.iteratorpattern.setvice.Iterator;

/*
 * 作者：m鹏h
 * 时间；2024/8/7 22:54
 * 描述：
 **/
public class ClassroomIterator  implements Iterator {

 private Classroom classroom;
 private int index ;

 public ClassroomIterator(Classroom classroom) {
  this.classroom = classroom;
  this.index = 0;
 }
 @Override
 public boolean hasNext() {
  return index < classroom.getSize();
 }

 @Override
 public Object next() {
Student student = classroom.getStudentAt(index);
index++;
return student;
 }
}























